package com.mtsmda.oracleOfficialTutorialJAVA7.chapter1;

import java.util.Arrays;
import java.util.List;

public class ArrayEx {
	
	public static void main(String[] args) {
		int [] array = {900, 150, 253, 24328, 152};
		System.out.println("length = " + array.length);
		for(int i : array){
			System.out.println(i);
		}
		
		int [][]multiArray = {
				{52, 69, 12, 13, 18},
				{52, 25, 254},
				{100}
		};
		System.out.println("multiArray length = " + multiArray.length);
		System.out.println("multiArray 1 length = " + multiArray[0].length);
		System.out.println("multiArray 2 length = " + multiArray[1].length);
		System.out.println("multiArray 3 length = " + multiArray[2].length);
		System.out.println("_______________________");
		char [] myFirstAndLastName = {'M', 'y', 'n', 'z', 'a', 't', ' ', 'D', 'm', 'i', 't', 'r', 'i', 'i'};
		charLoop(myFirstAndLastName);
		
		char [] myLastName = new char[7];
		System.arraycopy(myFirstAndLastName, 7, myLastName, 0, 7);
		charLoop(myLastName);
		
		char [] myFirstName = Arrays.copyOfRange(myFirstAndLastName, 0, 6);
		charLoop(myFirstName);
		System.out.println("_______________________");
		System.out.println(Arrays.binarySearch(myFirstName, 't'));
		charLoop(Arrays.copyOf(myFirstAndLastName, 9));
		System.out.println(Arrays.class.getCanonicalName());
		List<char[]> asList = Arrays.asList(myFirstAndLastName);
		System.out.println(asList.get(0));
		System.out.println(Arrays.toString(myFirstAndLastName));
		intLoop(array);
		Arrays.sort(array);
		intLoop(array);
	}
	
	private static void charLoop(char [] charA){
		for(char c : charA){
			System.out.print(c);
		}
		System.out.println();
	}
	
	private static void intLoop(int [] intA){
		for(int i : intA){
			System.out.print(i + " ");
		}
		System.out.println();
	}
}